<?php

namespace App\Http\Controllers\Api\Miniprogram;

use App\Http\Controllers\Controller;
use App\Models\Order\OrderSample;
use Illuminate\Support\Facades\Auth;

class AppointmentController extends Controller
{
    public function getList()
    {
        $userId = Auth::id();
        $orderSamples1 = OrderSample::with(['goodsOrder', 'checkItem', 'qrcode', 'testLocation', 'checkTime'])->whereHas('goodsOrder', function ($query) use ($userId) {
            $query->where('user_id', $userId)->whereIn('payment_status', [2]);
        })->whereIn('status', [1, 2])->orderByDesc('id')->get();
        $orderSamples2 = OrderSample::with(['goodsOrder', 'checkItem', 'qrcode', 'testLocation', 'checkTime'])->whereHas('goodsOrder', function ($query) use ($userId) {
            $query->where('user_id', $userId)->whereIn('payment_status', [2]);
        })->whereIn('status', [5])->orderByDesc('id')->get();
        return $this->successJson([
            'list1' => $orderSamples1,
            'list2' => $orderSamples2,
            'status_options' => trans('order-sample.options.appointment_status')
        ]);
    }
}
